package com.hdc.mumuwei.micro_account_server.controller;

import com.hdc.mumuwei.micro_account_server.po.Bill;
import com.hdc.mumuwei.micro_account_server.po.Paging;
import com.hdc.mumuwei.micro_account_server.service.BillService;
import com.hdc.mumuwei.micro_account_server.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Mumuwei
 * @Description
 * @create 2021/11/19 22:49
 */
@RestController
@RequestMapping("bill")
public class BillController {

    @Autowired
    BillService billService;

    /**
     * 获取账单列表（分页）
     *
     * @param paging
     */
    @GetMapping("getBillList")
    public Result getBillList(Paging paging){
        return billService.getBillList(paging);
    }

    /**
     * 获取账单列表（不分页）
     *
     * @param paging paging对象
     * @return
     */
    @GetMapping("getAllBliis")
    public Result getAllBills(Paging paging){
        return billService.getAllBills(paging);
    }

    @GetMapping("getBillById")
    public Result getBillById(Bill bill){
        return  billService.getBillById(bill);
    }

    /**
     * 添加账单
     *
     * @param bill 账单对象
     * @return
     */
    @PostMapping("addBill")
    public Result addBill(Bill bill){
        return billService.addBill(bill);
    }

    /**
     * 更新账单
     *
     * @param bill 账单信息
     * @return
     */
    @PostMapping("updateBill")
    public Result updateBill(Bill bill){
        return billService.updateBill(bill);
    }

    /**
     * 删除账单
     *
     * @param bill 用户uid 和 账单bid
     * @return
     */
    @DeleteMapping("deleteBill")
    public Result delBill(Bill bill){
        return billService.delBill(bill);
    }
}
